{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "D:\\software\\envs\\tensorflow\\lib\\site-packages\\sklearn\\ensemble\\weight_boosting.py:29: DeprecationWarning: numpy.core.umath_tests is an internal NumPy module and should not be imported. It will be removed in a future NumPy release.\n",
      "  from numpy.core.umath_tests import inner1d\n"
     ]
    }
   ],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "from imblearn.over_sampling import SMOTE\n",
    "from imblearn.under_sampling import RandomUnderSampler\n",
    "pathNew = 'D:/homework/pre/'\n",
    "dataLabel = pd.read_csv(pathNew+'dataLabel.csv')\n",
    "dataFeature = pd.read_csv(pathNew+'predataFeature.csv')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "WT_Faultcode\n",
      "0     1720488\n",
      "1        7869\n",
      "2       34984\n",
      "3           4\n",
      "4       49113\n",
      "5          17\n",
      "6      508334\n",
      "7        7156\n",
      "8          26\n",
      "9        1566\n",
      "10          8\n",
      "11       7716\n",
      "Name: WT_Faultcode, dtype: int64\n"
     ]
    }
   ],
   "source": [
    "grouped = dataLabel['WT_Faultcode'].groupby(dataLabel['WT_Faultcode'])\n",
    "print(grouped.count())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   iActivePoweiSetPointValue  iAvailabillityToday  iAvailabillityTotal  \\\n",
      "0                   0.089048               0.9999                  1.0   \n",
      "\n",
      "   iBlade1TempBattBox_1sec  iBlade1TempInvBox_1sec  iBlade1TempMotor_1sec  \\\n",
      "0                   0.6625                0.608939               0.591623   \n",
      "\n",
      "   iBlade1TempPMCHeatsink_1sec  iBlade1TempPMMHeatsink_1sec  \\\n",
      "0                     0.615527                     0.677003   \n",
      "\n",
      "   iBlade2TempBattBox_1sec  iBlade2TempInvBox_1sec  ...    iUL2_690V  \\\n",
      "0                 0.646154                0.642458  ...     0.961702   \n",
      "\n",
      "   iUL3_690V  iVaneDiiection  iVibrationY  iVibrationZ  iwindDirection  \\\n",
      "0   0.962238        0.509486     0.428339      0.50313        0.731762   \n",
      "\n",
      "   iWindSpeed  iYPLevel  WT_Runcode  label  \n",
      "0     0.24379       0.0    0.004566      0  \n",
      "\n",
      "[1 rows x 72 columns]\n"
     ]
    }
   ],
   "source": [
    "dataSet = dataFeature\n",
    "dataSet['label'] = dataLabel\n",
    "dataSet = dataSet.dropna(axis=1, how='all')\n",
    "dataSet.to_csv(pathNew+'dataSet.csv',index=0)\n",
    "print(dataSet.head(1))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "group1 = dataSet[(dataSet['label']==0)|(dataSet['label']==1)|(dataSet['label']==2)|(dataSet['label']==4)|(dataSet['label']==6)|(dataSet['label']==7)|(dataSet['label']==9)|(dataSet['label']==11)]\n",
    "group2 = dataSet[(dataSet['label']==3)|(dataSet['label']==5)|(dataSet['label']==8)|(dataSet['label']==10)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "label\n",
      "0     1720488\n",
      "1        7869\n",
      "2       34984\n",
      "4       49113\n",
      "6      508334\n",
      "7        7156\n",
      "9        1566\n",
      "11       7716\n",
      "Name: label, dtype: int64\n",
      "-------------------------\n",
      "label\n",
      "3      4\n",
      "5     17\n",
      "8     26\n",
      "10     8\n",
      "Name: label, dtype: int64\n"
     ]
    }
   ],
   "source": [
    "grouped1 = group1['label'].groupby(group1['label'])\n",
    "grouped2 = group2['label'].groupby(group2['label'])\n",
    "print(grouped1.count())\n",
    "print('-------------------------')\n",
    "print(grouped2.count())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "group1.to_csv(pathNew+'group1.csv',index=0)\n",
    "group2.to_csv(pathNew+'group2.csv',index=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
